#include <func.h>
#include "Network.h"
#include "Bussiness.h"

#define SERVPORT "9527"    //服务器端口号
#define MAXLINE 1024        

int main(int argc, char *argv[]){
    // ./client host
    if(argc != 2){
        error(1, 0, "Usage: ./client host");
    }

    int sockfd = tcp_connect(argv[1], SERVPORT);
    printf("sockfd = %d\n", sockfd);

    for(;;){
        //接收用户命令
        char cmd[MAXLINE];
        fgets(cmd, MAXLINE, stdin);
        //发送命令到服务器
        send(sockfd, cmd, strlen(cmd), 0);
    }

    //发送一个命令
    send(sockfd, "cmd", 3, 0);
    recv_file(sockfd);
    printf("INFO: %s downloaded\n", "file1");
    close(sockfd);

    return 0;
}
